import Vue from 'vue'
import vueResource from 'vue-resource'
Vue.use(vueResource);

let fetch = (info) => {
	let promise = new Promise(function(resolve, reject){
		Vue.http.jsonp(
			info.url, 
			{
				params: info.params,
				jsonp: info.jsonp || 'callback',
				jsonpCallback: info.jsonpCallback
			}
		)
		.then(
			response => {

				resolve(response.body);

			}, 
			response => {

				reject();

			}
		);
	});
	return promise;
};

export default fetch
